package com.triptogether.utils.androidsystem;

import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationCompat.BigTextStyle;
import android.support.v4.app.NotificationCompat.Builder;

import com.triptogether.R;

public class NotificationsManager {

	private static final int NOTIFICATION_ID_CHAT_MESSAGE = 1;

	private static NotificationCompat.Builder createBuilderNotification(Context context,
	        int smallIconId, String contentTitle, String content, boolean ongoing) {

		// Build notification
		NotificationCompat.Builder ncBuilder = new NotificationCompat.Builder(context);
		ncBuilder.setSmallIcon(smallIconId);
		ncBuilder.setContentTitle(contentTitle);
		ncBuilder.setContentText(content);
		ncBuilder.setOngoing(ongoing); // on going notifications can not be
									   // clean from the notifications panel

		return ncBuilder;
	}

	public static void notifyChatMessage(Context context, String fromUser, String message) {
		NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
		Builder ncBuilder = createBuilderNotification(context, R.drawable.ic_launcher, "Message from " + fromUser, 
		                                                      message, false);
		
		// Set the Big style
		BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
		bigTextStyle.bigText(message);
		ncBuilder.setStyle(bigTextStyle);
		Notification notification = ncBuilder.build();
		notification.vibrate = new long[]{100,100,100,100,100};
		
		notificationManager.notify(NOTIFICATION_ID_CHAT_MESSAGE, notification);
	}
}
